package com.xjf.springboot001.controller;

import com.xjf.springboot001.domain.User;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.UUID;

/**
 *
 * 功能描述: controller里面的方法都以json格式输出，不用再写什么jackjson配置的了！
 *
 * @param:
 * @return:
 * @auther: xujianfeng
 * @date: 2018/10/15 17:33
 */
@RestController
public class HelloWordController {
    /**
     * 测试输出HelloWord
     * @return the String
     */


    @RequestMapping(value = "/hello",method = RequestMethod.GET)
    public String index(){
        return "HelloWorld";
    }
    @RequestMapping("/uid")
    String uid(HttpSession session) {
        UUID uid = (UUID) session.getAttribute("uid");
        if (uid == null) {
            uid = UUID.randomUUID();
        }
        session.setAttribute("uid", uid);
        return session.getId();
    }

}
